<?xml version="1.0" encoding="ISO-8859-1" ?>
<!--

    Copyright (c) 2014, 2019 Oracle and/or its affiliates. All rights reserved.

    This program and the accompanying materials are made available under the
    terms of the Eclipse Distribution License v. 1.0, which is available at
    http://www.eclipse.org/org/documents/edl-v10.php.

    SPDX-License-Identifier: BSD-3-Clause

-->

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
      xmlns:h="http://xmlns.jcp.org/jsf/html"
      xmlns:f="http://xmlns.jcp.org/jsf/core"
      xmlns:util="http://java.sun.com/jsf/composite/util">

    <ui:composition template="/template.xhtml">
        <ui:define name="title">
            <h:outputText value="#{bundle.CreateProductTitle}"></h:outputText>
        </ui:define>
        <ui:define name="body">
            <h:panelGroup layout="block" id="step1" rendered="#{productController.step == 1}">
                <h:outputText value="Step 1 - Add a new product" style="font-size:20px;"/> 
                <h:form><br />
                    <h:panelGrid columns="2">
                        <h:outputLabel value="#{bundle.CreateProductLabel_name}" for="name" />
                        <h:inputText id="name" value="#{productController.selected.name}" title="#{bundle.CreateProductTitle_name}" required="true" requiredMessage="#{bundle.CreateProductRequiredMessage_name}"/>
                        <h:outputLabel value="#{bundle.CreateProductLabel_price}" for="price" />
                        <h:inputText id="price" value="#{productController.selected.price}" title="#{bundle.CreateProductTitle_price}" required="true" requiredMessage="#{bundle.CreateProductRequiredMessage_price}"/>
                        <h:outputLabel value="#{bundle.CreateProductLabel_description}" for="description" />
                        <h:inputText id="description" value="#{productController.selected.description}" title="#{bundle.CreateProductTitle_description}" required="true" requiredMessage="#{bundle.CreateProductRequiredMessage_description}"/>
                        <h:outputLabel value="#{bundle.CreateProductLabel_category}" for="category" />
                        <h:selectOneMenu id="category" value="#{productController.selected.category}" title="#{bundle.CreateProductTitle_category}" required="true" requiredMessage="#{bundle.CreateProductRequiredMessage_category}">
                            <f:selectItems value="#{categoryController.itemsAvailableSelectOne}" />
                        </h:selectOneMenu>
                    </h:panelGrid>

                    <util:commandButtons bundleEntity="CreateProduct" controller="#{productController}" type="create" />
                        
                </h:form>
                
            </h:panelGroup>
            <h:panelGroup layout="block" id="step2" rendered="#{productController.step == 2}">
                <h:outputText value="Step 2 - Upload the product image" style="font-size:20px;"/>
                
                <h:form id="upForm" enctype="multipart/form-data">
                    <h:panelGrid columns="2" rendered="#{productController.step == 2}">
                        <h:outputLabel value="#{bundle.CreateProductLabel_img}" for="file" />
                        <h:inputFile id="file" value="#{productController.filePart}"/>
                        <h:commandButton value="Upload"
                                         action="#{productController.upload}" onclick="return validateUpload()">
                            <f:ajax execute="file" render="@all"/>
                        </h:commandButton>
                        
                        <h:commandButton action="#{productController.done}" value="Finish!" rendered="#{productController.step == 3}" />
                    </h:panelGrid>
                </h:form>
            </h:panelGroup>

            <h:panelGroup layout="block" id="step3" rendered="#{productController.step == 3}">
                <br />
                <h:form>
                    <h:commandButton action="#{productController.done}" value="Done!" />
                </h:form>
            </h:panelGroup>

        </ui:define>
    </ui:composition>

</html>
